package org.dreamwork.cai.spring;

import org.dreamwork.cai.io.IRemoteServiceProvider;
import org.dreamwork.cai.io.impl.SimpleProvider;
import org.dreamwork.cai.proxy.IServiceResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class SpringTCPProvider implements IRemoteServiceProvider {
    private final SimpleProvider provider;

    public SpringTCPProvider () {
        this.provider = new SimpleProvider ();
    }

    @Autowired
    public void setResolver (IServiceResolver resolver) {
        provider.setServiceResolver (resolver);
    }

    @Override
    public void bind (int port) throws IOException {
        provider.bind (port);
    }

    @Override
    public void unbind () throws IOException {
        provider.unbind ();
    }
}
